﻿using Core.Models;
using Core.Tenant.Abstractions;
using Core.Tenant.Dtos;
using MediatR;

namespace Core.Tenant.Features.PaginationQuery;

public class TenantsWithPaginationQueryHandler :
         IRequestHandler<TenantsWithPaginationQuery, PaginatedData<TenantDetail>>
{
    private readonly ITenantService _tenantService;

    public TenantsWithPaginationQueryHandler(
        ITenantService tenantService)
    {
        _tenantService = tenantService;
    }

    public async Task<PaginatedData<TenantDetail>> Handle(TenantsWithPaginationQuery request, CancellationToken cancellationToken)
    {
        return await _tenantService.GetPageAsync(request, cancellationToken);
    }
}
